package leet.ku._28;

public class Solution {
	public int strStr(String haystack, String needle) {
    	if (haystack == null || needle == null || needle.length() > haystack.length())
    		return -1;
    	if (needle.length() <= 0)
    	    return 0;
    	for (int i = 0; i <= haystack.length() - needle.length(); i++) {
    		boolean check = true;
    		for (int j = 0; j < needle.length(); j++)
    			if (haystack.charAt(i + j) != needle.charAt(j)) {
    				check = false;
    				break;
    			}
    		if (check)
    			return i;
    	}
    	return -1;
    }
}